/* eslint-disable no-shadow */
const base = 'biz.coupon.batches';
export function count({ search }) {
  return RSocket.rr({
    route: `${base}.count`,
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: `${base}`,
    args: { search, pg },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `${base}.${id}`,
  });
}

export function update(channel) {
  return RSocket.rr({
    route: `${base}.update`,
    data: channel,
  });
}

export function create(channel) {
  return RSocket.rr({
    route: `${base}.create`,
    data: channel,
  });
}

export function remove(id) {
  return RSocket.rr({
    route: `${base}.${id}.delete`,
  });
}

export function getUserMobile(mobile) {
  return RSocket.rr({
    route: `users.bymobile.${mobile}`,
  });
}

export function applyBatch(args) {
  return RSocket.rr({
    route: `${base}.apply`,
    args: {
      ...args,
    },
  });
}

export function getActivity({ search = {} }) {
  return RSocket.rs({
    route: 'biz.activities',
    args: { search, pg: { size: 999 } },
  });
}

/**
 * @description 获取批次数量
 * @returns true
 */
export function getBatchCount({ search }) {
  return RSocket.rr({
    route: 'biz.coupon.applies.count',
    args: { search },
  });
}

/**
 * @description 获取卡券规则
 * @returns true
 */
export function getCouponCfg(id) {
  return RSocket.rr({
    route: `dmn.rules.coupon-${id}.exec.cfg`,
    data: {
      order: {},
      params: {},
    },
  });
}

